how to react to property changes in javascript